home *** CD-ROM | disk | FTP | other *** search
- #!/usr/sbin/perl
-
- # the global glossary location
-
- if (! $ENV{GLOBAL_GLOSS} ) {
- $GLOBAL_GLOSS="/hosts/bonnie.wpd/depot/doc/1000/007-1859-050/gloss.sgm";
- }
- else { $GLOBAL_GLOSS = $ENV{GLOBAL_GLOSS} }
-
- # test command line syntax
- $SGMLFILE=$ARGV[0];
- if ($SGMLFILE eq "") {
- print "Usage : glossQA <input-file-name>\n";
- exit;
- }
-
- # open the sgml file and make lists of all glossitems and b-o-b glossentries
- open(F,$SGMLFILE);
- while (<F>) {
- while (s/<GLOSSARYITEM>([^<]+)<\/GLOSSARYITEM>/$1/) {
- ($EXPR = $1) =~ s/\\/\\\\/;
- $EXPR =~ s/\(/\\\(/;
- $EXPR =~ s/\)/\\\)/;
- if (!grep(/^$EXPR$/,@GLOSSITEMS)) {
- push(@GLOSSITEMS,"$1");
- }
- }
- if (s/.*<GLOSSARYENTRY>(.*)<\/GLOSSARYENTRY>.*$/$1/) {
- while (s/^(.*)<[^>]+>(.*)$/$1$2/) { ; }
- push(@GLOSSENTRYS,"$1$2");
- }
- }
- close(F);
-
- # see if there are any unresolved items vis-a-vis b-o-b glossentries
- foreach $GLOSSITEM (@GLOSSITEMS) {
- ($EXPR = $GLOSSITEM) =~ s/\\/\\\\/;
- $EXPR =~ s/\(/\\\(/;
- $EXPR =~ s/\)/\\\)/;
- if (!grep(/^$EXPR$/,@GLOSSENTRYS)) {
- push(@UNRESOLVEDBOB_ITEMS,$GLOSSITEM);
- }
- }
-
- # if everything checks, say so and exit
- if (@UNRESOLVEDBOB_ITEMS eq "") {
- print "\n Unresolved Glossary terms present in this book: None\n";
- exit;
- }
-
- # if some items still unresolved open the global gloss, if there is one;
- # otherwise, print a list and exit
- if (open(F,$GLOBAL_GLOSS)) {
- while (<F>) {
- if (s/.*<GLOSSARYENTRY>(.*)<\/GLOSSARYENTRY>.*$/$1/) {
- while (s/^(.*)<[^>]+>(.*)$/$1$2/) { ; }
- push(@GLOBALGLOSSENTRYS,"$1$2");
- }
- }
- close(F);
- }
- else {
- print "\n Unresolved Glossary terms present in this book:\n";
- print " -----------------------------------------------\n";
- foreach $UNRESOLVEDBOB_ITEM (@UNRESOLVEDBOB_ITEMS) {
- print " \"$UNRESOLVEDBOB_ITEM\"";
- ($EXPR = $UNRESOLVEDBOB_ITEM) =~ s/\\/\\\\/;
- $EXPR =~ s/\(/\\\(/;
- $EXPR =~ s/\)/\\\)/;
- @MATCHES = grep(/$EXPR/,@GLOSSENTRYS);
- if ($MATCHES[0] ne "") {
- print " matches \"$MATCHES[0]\" (local)"; }
- print "\n";
- }
- exit;
- }
-
- # see if the global gloss resolves the items unresolved vis-a-vis b-o-b;
- # make a list of ones that don't
- foreach $UNRESOLVEDBOB_ITEM (@UNRESOLVEDBOB_ITEMS) {
- ($EXPR = $UNRESOLVEDBOB_ITEM) =~ s/\\/\\\\/;
- $EXPR =~ s/\(/\\\(/;
- $EXPR =~ s/\)/\\\)/;
- if (!grep(/^$EXPR$/,@GLOBALGLOSSENTRYS)) {
- push(@UNRESOLVED_ITEMS,$UNRESOLVEDBOB_ITEM);
- }
- }
-
- # if everything checks, say so
- if (@UNRESOLVED_ITEMS eq "") {
- print "\n Unresolved Glossary terms present in this book: None\n";
- }
- # if some items still unresolved, print them out, plus first grep match
- else {
- print "\n Unresolved Glossary terms present in this book:\n";
- print " -----------------------------------------------\n";
- foreach $UNRESOLVED_ITEM (@UNRESOLVED_ITEMS) {
- print " \"$UNRESOLVED_ITEM\"";
- ($EXPR = $UNRESOLVED_ITEM) =~ s/\\/\\\\/;
- $EXPR =~ s/\(/\\\(/;
- $EXPR =~ s/\)/\\\)/;
- @MATCHES = grep(/$EXPR/,@GLOSSENTRYS);
- if ($MATCHES[0] ne "") {
- print " matches \"$MATCHES[0]\" (local)"; }
- else {
- @MATCHES = grep(/$EXPR/,@GLOBALGLOSSENTRYS);
- if ($MATCHES[0] ne "") {
- print " matches \"$MATCHES[0]\" (global)";
- }
- }
- print "\n";
- }
- }
-